import { IPSSysBIHierarchy } from './ipssys-bihierarchy';
import { IPSSysBILevel } from './ipssys-bilevel';
import { IPSDataEntity } from '../dataentity/ipsdata-entity';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSysBIHierarchyImpl extends PSModelObjectImpl implements IPSSysBIHierarchy {
  protected allpssysbilevels: IPSSysBILevel[] | null = null;

  getAllPSSysBILevels(): IPSSysBILevel[] | null {
    if (this.allpssysbilevels == null) {
      this.allpssysbilevels = this.fillChildListModel(this.M.getAllPSSysBILevels, 'bi.IPSSysBILevel') as IPSSysBILevel[];
    }
    return this.allpssysbilevels;
  }

  get allPSSysBILevels(): IPSSysBILevel[] | null {
    return this.getAllPSSysBILevels();
  }

  findPSSysBILevel(objKey: any): IPSSysBILevel | null {
    return this.getPSModel5('bi.IPSSysBILevel', this.getAllPSSysBILevels(), objKey) as IPSSysBILevel;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get hierarchyTag(): string {
    return this.M.hierarchyTag;
  }

  get hierarchyTag2(): string {
    return this.M.hierarchyTag2;
  }

  get hierarchyType(): 'DE' {
    return this.M.hierarchyType;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdataentity: IPSDataEntity | null = null;

  getPSDataEntity(): IPSDataEntity | null {
    if (this.psdataentity != null) return this.psdataentity;
    const value = this.M.getPSDataEntity;
    if (value == null) {
      return null;
    }
    this.psdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getPSDataEntity') as IPSDataEntity;
    return this.psdataentity;
  }

  get psDataEntity(): IPSDataEntity | null {
    return this.getPSDataEntity();
  }

  getPSDataEntityMust(): IPSDataEntity {
    const value = this.getPSDataEntity();
    if (value == null) {
      throw new Error('未指定实体');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSSysBIHierarchyImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'bi.IPSBIHierarchy' || cls == 'bi.IPSSysBIHierarchy') return true;
    return super.instanceof(cls);
  }
}
